<?
$pageName = "course";
include ROOT . '/view/admin/common/header.php';
?>
<?
/**
 * @var	Course	$data
 */
?>

<div class="container">
    <br /><br />
    <? if(isset($_GET['succ'])) { ?><div class="alert alert-success" role="alert">操作成功！</div><? }?>
    <div class="page-header">
        <a href="/admin/course/" class="btn btn-warning" role="button" style="float:right;">返回课程列表</a>
        <h2><?= ($data->id) ? "修改课程" : "创建课程";?></h2>
    </div>
    <div class="row" style="margin-bottom:20px;">
        <div class="col-xs-8">
            <form class="form-horizontal" role="form" method="post">
                <? if ($data->id) { ?>
                <div class="form-group">
                    <label class="col-sm-1 control-label">ID</label>
                    <div class="col-sm-11">
                        <input name="id" type="text" class="form-control input-lg" value="<?=$data->id?>" readonly="readonly">
                    </div>
                </div>
                <? } ?>
                <?
                $show = [];
                $show['名称'] = 'name';
                $show['学时'] = 'period';
                $show['学分'] = 'credit';
                foreach ($show as $key => $value) {?>
                    <div class="form-group">
                        <label class="col-sm-1 control-label"><?=$key?></label>
                        <div class="col-sm-11">
                            <input name="<?=$value?>" type="text" class="form-control input-lg" value="<?=$data->$value?>"/>
                        </div>
                    </div>
                <? } ?>
                <div class="form-group">
                    <label class="col-sm-1 control-label">所属学院</label>
                    <div class="col-sm-11">
                        <select name="collegeId" class="form-control input-lg">
                            <? foreach (College::find(new TrueQuery()) as $college) { ?>
                                <option value="<?=$college->id?>" <?=($data->collegeId == $college->id) ? 'selected' : ''?> ><?=$college->name?></option>
                            <? } ?>
                        </select>
                    </div>
                </div>
                <p>&nbsp;</p>
                <div class="form-group">
                    <div class="col-sm-offset-1 col-sm-11">
                        <button type="submit" class="btn btn-danger btn-lg btn-block">提交！</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!-- .row -->

</div>
<? include ROOT . '/view/admin/common/footer.php'; ?>
